Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 42 |
| Duplication | 2 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
| */ | ||
| @Test | ||
| public void checkIsEncrypted() throws Exception { | ||
| String cipher = LegacyAesUtil.encrypt(INPUT, SECRET); |
| @Test | ||
| public void checkIsEncrypted() throws Exception { | ||
| String cipher = LegacyAesUtil.encrypt(INPUT, SECRET); | ||
| assertTrue(LegacyAesUtil.isEncrypted(cipher)); |
| assertTrue(LegacyAesUtil.isEncrypted(cipher)); | ||
|
|
||
| String potentialCipher = "Lorem Ipsum"; | ||
| assertFalse(LegacyAesUtil.isEncrypted(potentialCipher)); |
|
|
||
| String potentialCipher = "Lorem Ipsum"; | ||
| assertFalse(LegacyAesUtil.isEncrypted(potentialCipher)); | ||
| assertFalse(LegacyAesUtil.isEncrypted(Base64.encode(potentialCipher))); |
stweil
left a comment
There was a problem hiding this comment.
@thomaslow, please address the comments from github-advanced-security. It would be good to avoid deprecated code in new contributions.
|
@stweil I am not sure why "github-advanced-security" is not smart enough to realize that these warnings concern uses of deprecated methods and classes that were marked as deprecated by this very pull request. I marked the legacy password code as deprecated, but it is still required to migrate old password encodings to new ones. So, from now on, these deprecated classes and methods should not be used any more, but in this PR, these uses are necessary. I can't "dismiss" these github alerts from my side (the button is greyed out), otherwise, I would have already done so. |
|
Ah, okay. I am afraid that only @solth has the rights to dismiss the alerts from github-advanced-security. |
I am not sure I understand this part. If the usage of those classes and functions is still necessary (to migrate old password encodings), why mark them as "deprecated"? I understand they should not be used to encode passwords in the future, but they are still required for the migration. Is that really the definition of "deprecated"? Shouldn't they only be marked deprecated once an non-deprecated alternative exists? |
In my opinion, Of course, in this PR - today - I still use this code. But I didn't add this
I don't think |
henning-gerhardt
left a comment
There was a problem hiding this comment.
I tried your changes and the following usage scenarios are tested and are working:
- migrate from a plain password to latest supported algorithm
- migrate from a older encrypted password to latest supported algorithm
- changing password of a user
- creating new user and let his password store inside LDAP
Code is clean with only a small wrong indent.
This PR addresses two CodeQL security warnings about outdated encryption algorithms:
Related Issues
How it works
The class
AESUtilis needed to symmetrically encrypt Ldap manager passwords. These passwords are used to write credentials of users to an Ldap server (if configured). The secret key for this encryption can be configured inkitodo_config.propertiesviasecurity.secret.ldapManagerPassword.Currently,
AESUtiluses the encryption methodAES/CBC, which is generally not bad, but a bit outdated. This PR migrates passwords toAES/GCM, which is considered the current standard.This PR follows a similar strategy as #7188 and the Spring Security "DelegatingPasswordEncoder". It prefixes encrypted passwords with a unique identifier, e.g.,
{aes-gcm}, which is used to identify the encryption strategy for this password. Passwords that have previously stored without such a prefix are treated as "legacy" and are decrypted with the legacy decryption strategy. In the future, passwords can be easily migrated to new and better algorithms by adding another strategy implementation.In order to migrate passwords to the newest encryption algorithm, the button
LDAP Manager Passwörter migrierenon page "System -> Migrieren" can be used.Since Kitodo.Production needs to be capable of decrypting legacy passwords for some time, the CodeQL security warning message will remain active. The legacy class
AESUtil(nowLegacyAesUtil) has been marked as@Deprecated.UI Changes
The password input for ldap manager passwords was previously set up with
redisplay="true", meaning, the actual clear-text password was already embedded in the HTML, but there was no "eye" button for users to display the clear-text password. This PR adds the "eye" button and fixes a simple layout issue (the password input did not stretch to 100% width).I also added a
maxlengthrestriction of 128 characters to the password input such that you cannot enter passwords that will be encrypted to something that does not fit themanagerPassworddatabase column that only supports 255 characters (defined asVARCHAR(255)). A password with 128 characters is encoded with roughly ~250 characters. In case the encoding still doesn't fit, a general "Ldap Server cannot be saved" error is shown to the user (as implemented in the current main branch).Migration / Release Notes
LDAP Manager Passwörter migrierenon pageSystem -> Migrieren